package com.myway.service.impl;

import com.myway.dto.beans.PageQuery;
import com.myway.dao.SysPortalNewsMapper;
import com.myway.pojo.SysPortalNews;
import com.myway.service.SysPortalNewsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * Created by yufei on 2018/1/17.
 */
@Service
@Slf4j
public class SysPortalNewsServiceImpl implements SysPortalNewsService{

    @Autowired
    private SysPortalNewsMapper sysPortalNewsMapper;

    @Override
    public  List<SysPortalNews> itemDetailPage(String type) {
        List<SysPortalNews> sysPortalNewsList = sysPortalNewsMapper.selectByType(type);
        return sysPortalNewsList;
    }

    @Override
    public SysPortalNews getPageById(Long id) {
        SysPortalNews sysPortalNews = sysPortalNewsMapper.selectByPrimaryKey(id);
        return sysPortalNews;
    }

    @Override
    public int count(String type) {
        int count = sysPortalNewsMapper.count(type);
        return count;
    }

    @Override
    public  List<SysPortalNews> page(PageQuery page, String type) {
        List<SysPortalNews> sysPortalNewsList = sysPortalNewsMapper.page(page,type);
        return sysPortalNewsList;
    }

    /**
     * 查找本条内容下一条内容
     * @param operateTime 操作时间
     * @param type 内容类型
     * @return
     */
    @Override
    public SysPortalNews getPrePageById(Date operateTime,String type) {
        SysPortalNews sysPortalNews = sysPortalNewsMapper.prePage(operateTime, type);
        return sysPortalNews;
    }

    /**
     * 查找本条内容下一条内容
     * @param operateTime 操作时间
     * @param type 内容类型
     * @return
     */
    @Override
    public SysPortalNews getNextPageById(Date operateTime, String type) {
        SysPortalNews sysPortalNews = sysPortalNewsMapper.nextPage(operateTime, type);
        return sysPortalNews;
    }
}
